﻿public class ChatObject
{
    /// <summary>
    /// 聊天对象Id
    /// </summary>
    public string Id { get; set; }
    /// <summary>
    /// 聊天对象名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 比较两个对象的值是否相等
    /// </summary>
    /// <param name="obj">欲比较的对象</param>
    /// <returns></returns>
    public override bool Equals(object obj)
    {
        if (obj == null || !(obj is ChatObject))
            return false;
        if (obj == this)
            return true;
        ChatObject chatObject = obj as ChatObject;
        if (chatObject.Id == Id && chatObject.Name == Name)
            return true;
        return false;
    }
    /// <summary>
    /// 获取聊天对象哈希码
    /// </summary>
    /// <returns></returns>
    public override int GetHashCode()
    {
        return Id.GetHashCode();      
    }
    /// <summary>
    /// 格式化输出聊天对象
    /// </summary>
    /// <returns></returns>
    public override string ToString()
    {
        return $"Id:{Id}\tName:{Name}";
    }
}
